#include "Monitor.hpp"

class Proc
{
public:

	Proc():
		_id(0),
		_requesting_cs(false),
		_seq_no(0),
		_highest_seq_no(0),
		_outstanding_reply(2),
		_tick_count(0),
		_num_sent(0),
		_num_recev(0)
	{Initialization();}
	void Initialization();
	int wait_recv(Message &msg, unsigned int now);
	void wait_sent(Message &msg, unsigned int now, unsigned int should_sent);
	int get_num_sent2me(unsigned int now);
	void wait_sent2me(Message &msg, unsigned int now, unsigned int num_sent2me);
	bool update_tick_count();
	string request(int me, unsigned now, vector< vector<string> > content);
	list<Message> wait_recv_all(unsigned int now);
	string reply(int node, unsigned deliv);
	int get_lower(int me);
	int get_upper(int me);
	void send_log(string info);
	void send_finish();
	void send_term();
	void send_num_sent(int n0, int n1, int n2);
	void send_num_sent(vector<int> v_sent);
	vector<int> update_sent_vec(int to_node, vector<int> &v_sent);
	list<Message> wait_deliv_all(unsigned int now);
	void read_own_thing(string fileName, list< list< vector<string> > >& content, int me);


	void recv_next();
	int get_tick_count();

	void uni_reply();
	void brod_reply();
	string gen_log();
	string get_sent();
	string read_message();
	void set_recv();
	bool wait_recv();
	bool is_finish();

	int _id;
	bool _requesting_cs;
	//bool _in_critical_section;
	int _seq_no;
	int _highest_seq_no;
	int _outstanding_reply;
	int _tick_count;
	int _num_sent;
	int _num_recev;
	list<Message> l_delivered;
	list<Message> l_defer;
	list<Message> l_sent;
	Communication _comm;
	vector< vector<string> > _config;
};

